﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MINERP.BLL.Statistics;
using MINERP.DAL.CommonDAL;

namespace MINERP.Statistics.Forms
{
    public partial class FrmShopCrushAndArrears : Form
    {
        ShopCrushAndArrearsBLL bll = new ShopCrushAndArrearsBLL();
        private static FrmShopCrushAndArrears _instance = null;
        private  FrmShopCrushAndArrears()
        {

            InitializeComponent();
        }

        public static FrmShopCrushAndArrears GetInstance
        {
            get
            {
                _instance = new FrmShopCrushAndArrears();
                return _instance;
            }
        }
        private void simpleButtonOk_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            simpleButtonOk.Enabled = false;

            try
            {
                reportShopCrushAndArrears.Preview = previewControl1;
                reportShopCrushAndArrears.RegisterData(bll.GetShopCrushAndArrears(dateEditStartTime.DateTime, dateEditEndTime.DateTime));

                reportShopCrushAndArrears.Load(Application.StartupPath + "\\ShopCrushAndArrears.frx");
                reportShopCrushAndArrears.SetParameterValue("startTime", dateEditStartTime.DateTime);
                reportShopCrushAndArrears.SetParameterValue("endTime", dateEditEndTime.DateTime);
                previewControl1.Refresh();
                previewControl1.Show();
                reportShopCrushAndArrears.Show();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    
            }
            finally
            {
                simpleButtonOk.Enabled = true;
                this.Cursor = Cursors.Default;
            }
        }

        private void FrmPrintPaper_FormClosing(object sender, FormClosingEventArgs e)
        {
            _instance = null;
        }

        private void FrmPrintPaper_Load(object sender, EventArgs e)
        {
            dateEditStartTime.DateTime = DateTime.Now.Date;
            dateEditEndTime.DateTime = DateTime.Now;
        }
    }
}
